Adam
Adam
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
No description
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
No description
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
oh interesting i'll check it out ty
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
ok tyty nice pfp btw s2 when
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
in Cell i have a PopulateCell function that takes in a list of EntityData and goes through and instantiates and initialises each Entity with its EntityData to load the world from a save how do i differentiate between different EntityData ? maybe make it abstract as well and have each Entity have a different type of data, or maybe through an enum?
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
tyty i'll look at implementing this now
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
okay gotcha
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
inelegant maybe is the right word
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
it feels a bit awkward
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
idk people tend to avoid big if else statements
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
that was my first thought but i was thinking there has to be a better way of doing it
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Structure of system with polymorphism
1. no 2. yes if i use an abstract class, how do i differentiate between the classes that inherit from CellEntity in Cell?
21 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
i call this function to add all stats basically since each data object will need a different set of stats when my data objects are initialised since i don't know how to do it at construction (in unity)
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
ohh nice tip ty
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
oh and is there a similarly more performant way to implement this function? i haven't changed the Stat class to implement an interface yet so keep that in mind i use the dict of stats i got from the other function and then take in another dict of stats that i want to add stats to, but only add them if the dict doesn't already have them
public void AddMissingStatsWithTag(Dictionary<string, Stat> dict, string tagName)
{
Dictionary<string, Stat> fullDict = StatsWithTag(tagName);

foreach (KeyValuePair<string, Stat> pair in fullDict)
{
if (!dict.ContainsKey(pair.Key))
{
dict.Add(pair.Key, pair.Value);
}
}
}
public void AddMissingStatsWithTag(Dictionary<string, Stat> dict, string tagName)
{
Dictionary<string, Stat> fullDict = StatsWithTag(tagName);

foreach (KeyValuePair<string, Stat> pair in fullDict)
{
if (!dict.ContainsKey(pair.Key))
{
dict.Add(pair.Key, pair.Value);
}
}
}
alternatively a way to do this innately without a function, i've looked for that but couldn't find a good solution
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
okay i see i see tyty i'll try this out
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
not sure if you saw this, could you explain the TEntity interface implementation?
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
gotcha gotcha
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
oh i see that's sick, ty
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
and why is this a task and what does where TEntity : INeeded do?
24 replies